<template>
    <van-nav-bar title="退货详情" left-text="" left-arrow @click-left="goBack" />
    <section class="aui-flexView">
        <!-- 订单详细 -->
        <section class="aui-scrollView">
            <!-- 订单状态 -->
            <div class="aui-pay-change">
                <div class="aui-flex">
                    <div class="aui-flex-box">
                        <h3>{{ info.status_text }}</h3>
                    </div>
                    <div class="aui-pay-zfb">
                        <img src="/assets/images/icon-zfb.png" alt="" />
                    </div>
                </div>
            </div>

            <!-- 退货地址 -->
            <div class="aui-flex">
                <div style="font-size: 16px">退货地址：</div>
                <div class="aui-flex-box">
                    <h3>
                        {{ info.store.aftercare }} <em> {{ info.store.phone }}</em>
                    </h3>
                    <p> {{ info.store.address }}</p>
                </div>
            </div>

            <!-- 退货理由 -->
            <div class="aui-flex">
                <div style="font-size: 16px">退货理由：</div>
                <div class="aui-flex-box">
                    {{ info.business_reason }}
                </div>
            </div>

            <!-- 寄件地址 -->
            <div class="aui-flex" v-if="info.back_text">
                <div style="font-size: 16px">寄件地址：</div>
                <div class="aui-flex-box">
                    <h3>
                        {{ info.backinfo.contact }} <em>{{ info.backinfo.phone }}</em>
                    </h3>
                    <p>{{ info.backinfo.region_text + info.backinfo.address }}</p>
                </div>
            </div>

            <!-- 商家协商 -->
            <div class="aui-flex" v-if="info.admin_reason">
                <div style="font-size: 16px">商家协商：</div>
                <div class="aui-flex-box">
                    {{ info.admin_reason }}
                </div>
            </div>

            <!-- 商品信息 -->
            <div class="aui-commodity-bg">
                <div class="item" v-for="item in info.detail" :key="item.id">
                    <div class="aui-flex">
                        <div class="aui-commodity-img">
                            <router-link :to="{ path: '/product/info', query: { proid: item.proid } }">
                                <img :src="item.product.thumbs_text" />
                            </router-link>
                        </div>
                        <div class="aui-flex-box">
                            <h4 class="van-ellipsis">商品名称：{{ item.product.name }}</h4>
                            <p>商品单价：￥{{ item.price }}</p>
                            <span class="aui-barter-time">七天退换</span>
                        </div>
                        <div>
                            <h5>￥{{ item.total }}</h5>
                            <p class="aui-sml-text">X{{ item.pronum }}</p>
                        </div>
                    </div>
                </div>
            </div>

            <!-- 退货物流信息 -->
            <van-steps direction="vertical" :active="0">
                <van-step v-for="(item, index) in info.expresslist" :key="index">
                    <h3>{{ item.status }}</h3>
                    <p>{{ item.time }}</p>
                </van-step>
            </van-steps>
        </section>
    </section>
</template>
<script setup>
const { proxy } = getCurrentInstance()
const LoginUser = reactive(proxy.$cookies.get('LoginUser'));
const goBack = () => {
    proxy.$router.push('/order/index')
}
const orderid = ref(proxy.$route.query.orderid ?? 0)
const info = ref({
    address: {},
    store: {},
    backinfo: {},
    expresslist: []
})
const expresslist = ref([])
onBeforeMount(() => {
    getOrderInfoData()
})
const getOrderInfoData = async () => {
    let result = await Api.OrderInfo({
        busid: LoginUser.id,
        orderid: orderid.value
    })
    if (result.code == 1) {
        info.value = result.data
    }
}
</script>
<style>
@import url('/assets/css/info.css');
</style>